package com.ahzx.report.controller;

import com.ahzx.report.request.ReportQuery;
import com.ahzx.report.response.FinanceResponse;
import com.ahzx.report.service.ReportService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @Author syg
 * @Date 2021/4/23 16:45
 * @Desc To be or not to be,that is a question.
 */
@RestController
@RequestMapping("/report")
public class FinanceReportController extends BaseController {


    @Autowired
    private ReportService reportService;

    /**
     * 银企对接会统计报表
     *
     * @param reportQuery
     * @return
     */
//    @PreAuthorize("@ss.hasPermi('report:finance:list')")
    @GetMapping("/finance/list")
    public TableDataInfo financeList(ReportQuery reportQuery) {
        startPage();
        List<FinanceResponse> financeResponses = reportService.selectFinanceReportList(reportQuery);
        return getDataTable(financeResponses);
    }

    /**
     * 银企对接会统计报表导出
     * @param reportQuery
     * @return
     */
    @Log(title = "银企对接会统计报表", businessType = BusinessType.EXPORT)
//    @PreAuthorize("@ss.hasPermi('report:demand:export')")
    @GetMapping("/finance/export")
    public AjaxResult export(ReportQuery reportQuery) {
        List<FinanceResponse> list = reportService.selectFinanceReportList(reportQuery);
        ExcelUtil<FinanceResponse> util = new ExcelUtil<>(FinanceResponse.class);
        return util.exportExcel(list, "银企对接会统计报表");
    }

}
